home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 03 - 1987 / 03.02 Feb 87 / MacApp Text Editor / UDemoText.inc1.p < prev    next >
Encoding:
Text File  |  1986-12-31  |  15.7 KB  |  659 lines  |  [TEXT/MPS ]

  1. {Copyright © 1986 by Apple Computer, Inc.  All Rights Reserved.}
  2.  
  3. {UDemoText.inc1.p}
  4.  
  5.  
  6. CONST
  7.  
  8.   {Menu id's}
  9.     mFont        = 6;
  10.     mStyle        = 7;
  11.  
  12.  
  13.   {Command numbers for font-size commands}
  14.       cSizeChange    =    1100;
  15.     cSizeBase    =    1100;
  16.     cSizeMin    =    1109;
  17.     cSizeMax    =    1124;
  18.     {1101-1199 reserved for font sizes 1-99 pts.}
  19.  
  20.  
  21.   {Command numbers for typestyle attributes}
  22.       cStyleChange =    1200;
  23.     cPlainText    =    1201;
  24.     cBold        =    1202;
  25.     cItalic     =    1203;
  26.     cUnderline    =    1204;
  27.     cOutline    =    1205;
  28.     cShadow     =    1206;
  29.     cCondense    =    1207;
  30.     cExtend     =    1208;
  31.  
  32.     {Command numbers to cover other stylistic changes}
  33.     cJustChange    =    1300;
  34.     cFontChange =    1301;
  35.  
  36.     {Constant for staggering windows}
  37.     kStaggerAmount    = 16;
  38.  
  39.     {Constants for the text specs resource}
  40.     kTextSpecsRsrcType =    'SPEC';
  41.     kTextSpecsRsrcID =        1;
  42.     
  43.     {Constants for the print info resource}
  44.     kPrintInfoRsrcType =    'PRNT';
  45.     kPrintInfoRsrcID =        1;
  46.     
  47.     {The 'File is too large' alert}
  48.     kFileTooBig =            1000;
  49.  
  50. VAR
  51.     gFontNum:    INTEGER; {Font number - default for new documents}
  52.     gFontSize:    INTEGER; {Font Size in points - default for new documents}
  53.     gStaggerCount:    INTEGER;
  54.  
  55.  
  56.     PROCEDURE OutlineFontSizes(fontNum: INTEGER); FORWARD;
  57.         {Makes the right Menu Manager calls so that the 'Font' menu has
  58.             fontsizes representing 'natural fonts' shown in 'outline', and
  59.             sizes which can only be achieved by scaling another font size
  60.             shown in normal face}
  61.  
  62.  
  63. {$S AInit}
  64.     PROCEDURE  TDemoTextApplication.IDemoTextApplication;
  65.         VAR err:        OSErr;
  66.             fntName:    Str255;
  67.     BEGIN
  68.         (*InitPrinting;*)
  69.  
  70.         IApplication(kFileType);
  71.  
  72.         {Find out what applFont maps to, so that we set gFontNum to a real
  73.             font number.}
  74.         GetFontName(applFont, fntName);
  75.         GetFNum(fntName, gFontNum);
  76.         gFontSize := 10;
  77.  
  78.         IF NOT gFinderPrinting THEN
  79.             BEGIN
  80.             AddResMenu(GetMHandle(mFont), 'FONT');
  81.     
  82.             OutlineFontSizes(gFontNum);
  83.             gStaggerCount := 0;
  84.     
  85.             {Set style-items to corresponding typeface}
  86.             SetStyle(cBold, [bold]);
  87.             SetStyle(cUnderline, [underline]);
  88.             SetStyle(cItalic, [italic]);
  89.             SetStyle(cOutline, [outline]);
  90.             SetStyle(cShadow, [shadow]);
  91.             SetStyle(cCondense, [condense]);
  92.             SetStyle(cExtend, [extend]);
  93.             END;
  94.     END;
  95.  
  96.  
  97. {$S AOpen}
  98.     FUNCTION  TDemoTextApplication.DoMakeDocument(itsCmdNumber: CmdNumber):
  99.             TDocument; OVERRIDE;
  100.         VAR aTextDocument:    TTextDocument;
  101.  
  102.     BEGIN
  103.         New(aTextDocument);
  104.         FailNIL(aTextDocument);
  105.         aTextDocument.ITextDocument;
  106.         DoMakeDocument := aTextDocument;
  107.     END;
  108.  
  109.  
  110. {$IFC qDebug}
  111. {$S ADebug}
  112.     PROCEDURE TDemoTextApplication.IdentifySoftware;
  113.     BEGIN
  114.         WriteLn('DemoText Source date: 23 April 86; Compiled: ',
  115.                 COMPDATE, ' @ ', COMPTIME);
  116.         INHERITED IdentifySoftware;
  117.     END;
  118. {$ENDC}
  119.  
  120.  
  121. {$S AOpen}
  122.     PROCEDURE TTextDocument.ITextDocument;
  123.     BEGIN
  124.         fText := NIL;
  125.         IDocument(kFileType, kSignature, kUsesDataFork, kUsesRsrcFork,
  126.                     NOT kDataOpen, NOT kRsrcOpen);
  127.  
  128.         fTEView := NIL;
  129.         fText := NewPermHandle(0);
  130.         FailNIL(fText);
  131.     END;
  132.  
  133.  
  134.     {$S AClose}
  135.     PROCEDURE TTextDocument.Free; OVERRIDE;
  136.     BEGIN
  137.         IF fText <> NIL THEN
  138.             DisposHandle(fText);
  139.         INHERITED Free;
  140.     END;
  141.  
  142.  
  143.     {$S AOpen}
  144.     PROCEDURE TTextDocument.DoInitialState; OVERRIDE;
  145.     
  146.     BEGIN
  147.         WITH fTextSpecs DO
  148.             BEGIN
  149.             theFontNumber := gFontNum;
  150.             theFontSize := gFontSize;
  151.             theStyle := [];
  152.             theJustification := teJustLeft;
  153.             END;
  154.         fSpecsChanged := TRUE;
  155.     END;
  156.  
  157.  
  158.     {$S AOpen}
  159.     PROCEDURE TTextDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
  160.         VAR aTEView:    TTEView;
  161.             itsExtent:    Rect;
  162.             aHandler:    TStdPrintHandler;
  163.  
  164.     BEGIN
  165.         New(aTEView);
  166.         FailNIL(aTEView);
  167.         aTEView.ITEView(
  168.             NIL,                    {parent}
  169.             SELF,                    {its document}
  170.             fText,                    {its Text}
  171.             Point(0),                {location of its top-left-most point}
  172.             cTyping,                {its key-command number}
  173.             10,                     {10 pixels of margin on each side}
  174.             8,                        {8 pixels margin at top}
  175.             1000,                    {1000 pixels initial view width -- will be
  176.                                         adjusted to be width of page later}
  177.             100,                    {100 pixels initial height -- will be
  178.                                         adjusted to height-of-content later}
  179.             fTextSpecs.theFontNumber,{font family to use}
  180.             fTextSpecs.theFontSize, {font size to use}
  181.             fTextSpecs.theStyle,    {style to use}
  182.             sizePage,                {view width determined (initially) by page-
  183.                                         width less desired margins}
  184.             sizeVariable,            {height determined (initially) by amount of
  185.                                         text}
  186.             kUnlimited                {no limit to number of characters accepted}
  187.                 );
  188.  
  189.         aTEView.fHTE^^.just := fTextSpecs.theJustification;
  190.  
  191.         New(aHandler);
  192.         FailNIL(aHandler);
  193.         aHandler.IStdPrintHandler(aTEView, FALSE);
  194.         aHandler.fMinimalMargins := FALSE;
  195.  
  196. {$IFC qDebug}
  197.         aTEView.fShowBorders := TRUE;
  198.         aTEView.fShowExtraFeedback := TRUE;
  199. {$ENDC}
  200.         fTEView := aTEView;
  201.     END;
  202.  
  203.  
  204.     {$S AOpen}
  205.     PROCEDURE TTextDocument.DoMakeWindows; OVERRIDE;
  206.     VAR
  207.         aWindow:    TWindow;
  208.     BEGIN
  209.         aWindow := NewSimpleWindow(kWindowRsrcID, NOT kDialogWindow,
  210.                                    kWantHScrollBar, kWantVScrollBar, fTEView);
  211.         AdaptToScreen(aWindow);
  212.         SimpleStagger(aWindow, kStaggerAmount, kStaggerAmount, gStaggerCount);
  213.     END;
  214.  
  215.  
  216.     {$S ASelCommand}
  217.     FUNCTION  TTextDocument.DoMenuCommand(aCmdNumber: CmdNumber): TCommand;
  218.         VAR sd:             SizeDeterminer;
  219.             aName:            Str255;
  220.             menu:            INTEGER;
  221.             item:            INTEGER;
  222.             newSpecs:        TextSpecs;
  223.             aStyleItem:     StyleItem;
  224.         PROCEDURE InstallChangedDeterminer(vhs: VHSelect);
  225.         BEGIN
  226.             IF sd <> fTEView.fSizeDeterminer[vhs] THEN
  227.                 BEGIN
  228.                 fTEView.fSizeDeterminer[vhs] := sd;
  229.                 {If we changed the horizontal size determiner, we
  230.                     must ask the TTEView to recompute the TE
  231.                     rectangles.}
  232.                 IF vhs = h THEN
  233.                     BEGIN
  234.                     IF sd = sizeFrame THEN
  235.                         fTEView.FrameChangedSize
  236.                     ELSE IF sd = sizePage THEN
  237.                         fTEView.DoPagination;
  238.                     END;
  239.                 fTEView.AdjustExtent;
  240.                 fTEView.fFrame.ForceRedraw;
  241.                 END;
  242.         END;
  243.  
  244.         PROCEDURE LaunchTextCommand(aCmdNumber: CmdNumber);
  245.             VAR aTextCommand:    TTextCommand;
  246.  
  247.         BEGIN
  248.             New(aTextCommand);
  249.             FailNIL(aTextCommand);
  250.             WITH newSpecs DO
  251.                 aTextCommand.ITextCommand(aCmdNumber, SELF, fTEView,
  252.                                           theFontNumber, theFontSize,
  253.                                           theStyle, theJustification);
  254.             DoMenuCommand := aTextCommand;
  255.         END;
  256.     BEGIN
  257.         DoMenuCommand := gNoChanges;
  258.  
  259.         newSpecs := fTextSpecs;
  260.  
  261.         CmdToMenuItem(aCmdNumber, menu, item);
  262.         IF (cSizeMin <= aCmdNumber) AND (aCmdNumber <= cSizeMax) THEN
  263.             BEGIN
  264.             newSpecs.theFontSize := aCmdNumber - cSizeBase;
  265.             LaunchTextCommand(cSizeChange);
  266.             END
  267.  
  268.          ELSE
  269.          IF menu = mFont THEN
  270.             BEGIN
  271.             GetItem(GetMHandle(menu), item, aName);
  272.             GetFNum(aName, newSpecs.theFontNumber);
  273.             LaunchTextCommand(cFontChange);
  274.             END
  275.  
  276.         ELSE
  277.         IF (aCmdNumber >= cJustLeft) AND (aCmdNumber <= cJustRight) THEN
  278.             BEGIN
  279.             WITH newSpecs DO
  280.                 IF aCmdNumber = cJustLeft THEN
  281.                     theJustification := teJustLeft
  282.                 ELSE
  283.                 IF aCmdNumber = cJustCenter THEN
  284.                     theJustification := teJustCenter
  285.                 ELSE
  286.                     theJustification := teJustRight;
  287.  
  288.             LaunchTextCommand(cJustChange);
  289.             END
  290.  
  291.         ELSE
  292.         IF (aCmdNumber = cPlainText) THEN
  293.             BEGIN
  294.             newSpecs.theStyle := [];
  295.             LaunchTextCommand(cStyleChange);
  296.             END
  297.  
  298.         ELSE
  299.         IF (aCmdNumber > cPlainText) AND (aCmdNumber <= cExtend) THEN
  300.             BEGIN
  301.             CASE aCmdNumber OF
  302.                 cBold:            aStyleItem := bold;
  303.                 cItalic:        aStyleItem := italic;
  304.                 cUnderline:     aStyleItem := underline;
  305.                 cOutline:        aStyleItem := outline;
  306.                 cShadow:        aStyleItem := shadow;
  307.                 cCondense:        aStyleItem := condense;
  308.                 cExtend:        aStyleItem := extend;
  309.                 END; {case}
  310.             WITH newSpecs DO
  311.                 IF aStyleItem IN theStyle THEN
  312.                     theStyle := theStyle - [aStyleItem]
  313.                 ELSE
  314.                     theStyle := theStyle + [aStyleItem];
  315.             LaunchTextCommand(cStyleChange);
  316.             END
  317.  
  318.         ELSE
  319.         IF (aCmdNumber <= cWidthOnePage) AND (aCmdNumber >= cWidthFrame) THEN
  320.             BEGIN
  321.             IF aCmdNumber = cWidthFrame THEN
  322.                 sd := sizeFrame
  323.             ELSE
  324.             IF aCmdNumber = cWidthOnePage THEN
  325.                 sd := sizePage
  326.             ELSE
  327.                 sd := sizeFixed;
  328.  
  329.             {NB: The following is not undoable in the current version}
  330.             InstallChangedDeterminer(h);
  331.             END
  332.  
  333.         ELSE
  334.         IF (aCmdNumber >= cHeightFrame) AND (aCmdNumber <= cHeightConst) THEN
  335.             BEGIN
  336.             IF aCmdNumber = cHeightFrame THEN
  337.                 sd := sizeFrame
  338.             ELSE
  339.             IF aCmdNumber = cHeightPages THEN
  340.                 sd := sizeFillPages
  341.             ELSE
  342.             IF aCmdNumber = cHeightText THEN
  343.                 sd := sizeVariable
  344.             ELSE
  345.             IF aCmdNumber = cHeightConst THEN
  346.                 sd := sizeFixed;
  347.  
  348.             {NB: The following is not undoable in the current version}
  349.             InstallChangedDeterminer(v);
  350.             END
  351.  
  352.         ELSE
  353.             DoMenuCommand := INHERITED DoMenuCommand(aCmdNumber);
  354.     END;
  355.  
  356.  
  357.  
  358.     {$S AWriteFile}
  359.     PROCEDURE TTextDocument.DoNeedDiskSpace(VAR dataForkBytes,
  360.                                                 rsrcForkBytes: LONGINT);
  361.     BEGIN
  362.         dataForkBytes := dataForkBytes + GetHandleSize(fText);
  363.         
  364.         rsrcForkBytes := rsrcForkBytes +
  365.                 SIZEOF(TextSpecs) + kRsrcTypeOverhead + kRsrcOverhead +
  366.                 kPrintInfoSize + kRsrcTypeOverhead + kRsrcOverhead;
  367.  
  368.         INHERITED DoNeedDiskSpace(dataForkBytes, rsrcForkBytes);
  369.     END;
  370.  
  371.  
  372.     {$S AReadFile}
  373.     PROCEDURE TTextDocument.DoRead(aRefNum: INTEGER;
  374.                                    rsrcExists, forPrinting: BOOLEAN);
  375.         VAR numChars:        LONGINT;
  376.             hTextSpecs:        TextSpecsHdl;
  377.             hPrintInfo:        Handle;
  378.  
  379.     BEGIN
  380.         {Read the text}
  381.         FailOSErr(GetEOF(aRefNum, numChars));
  382.  
  383.         {The file may have been created by someone else--make sure we don't
  384.             read more than we can handle}
  385.         IF numChars > kUnlimited THEN
  386.             BEGIN
  387.             gApplication.ShowError(0, msgAlert + kFileTooBig);
  388.             numChars := kUnlimited;
  389.             END;
  390.  
  391.         SetHandleSize(fText, numChars);
  392.         FailMemError;
  393.         FailOSErr(FSRead(aRefNum, numChars, fText^));
  394.         
  395.         {Read the text specs resource}
  396.         hTextSpecs := TextSpecsHdl(GetResource(kTextSpecsRsrcType,
  397.                                                kTextSpecsRsrcID));
  398.         IF hTextSpecs <> NIL THEN
  399.             fTextSpecs := hTextSpecs^^
  400.         ELSE
  401.             WITH fTextSpecs DO
  402.                 BEGIN
  403.                 theFontNumber := gFontNum;
  404.                 theFontSize := gFontSize;
  405.                 theStyle := [];
  406.                 theJustification := teJustLeft;
  407.                 END;
  408.         fSpecsChanged := TRUE;
  409.         
  410.         {Read the print info resource}
  411.         hPrintInfo := GetResource(kPrintInfoRsrcType, kPrintInfoRsrcID);
  412.         IF hPrintInfo <> NIL THEN    {no print info resources was saved}
  413.             BEGIN
  414.             IF fPrintInfo = NIL THEN
  415.                 BEGIN
  416.                 fPrintInfo := NewPermHandle(kPrintInfoSize);
  417.                 FailNIL(fPrintInfo);
  418.                 END;
  419.             BlockMove(hPrintInfo^, fPrintInfo^, kPrintInfoSize);
  420.             END;
  421.     END;
  422.  
  423.  
  424.     {$S ARes}
  425.     PROCEDURE TTextDocument.DoSetupMenus;
  426.         VAR sd:             SizeDeterminer;
  427.             just:            INTEGER;
  428.             item:            INTEGER;
  429.             fnt:            INTEGER;
  430.             c:                INTEGER;
  431.             aName:            Str255;
  432.             aMenuHandle:    MenuHandle;
  433.             aStyle:         Style;
  434.     BEGIN
  435.         INHERITED DoSetupMenus;
  436.  
  437.         aMenuHandle := GetMHandle(mFont);
  438.         FOR item := 1 TO CountMItems(aMenuHandle) DO
  439.             BEGIN
  440.             {There can be more than 31 menu entries with scrolling menus,
  441.                 but trying to enable an item with number > 31 is bad news.
  442.                 If the menu itself is enabled (which it will be in MacApp
  443.                 if any of the first 31 items is enabled), then the extras
  444.                 will always be enabled.}
  445.             IF item <= 31 THEN
  446.                 EnableItem(aMenuHandle, item);
  447.             IF fSpecsChanged THEN
  448.                 BEGIN
  449.                 GetItem(aMenuHandle, item, aName);
  450.                 GetFNum(aName, fnt);
  451.                 IF fnt = fTextSpecs.theFontNumber THEN
  452.                     fCurrFontMenu := item;
  453.                 END;
  454.             END;
  455.         CheckItem(aMenuHandle, fCurrFontMenu, TRUE);
  456.  
  457.         FOR c := cSizeMin TO cSizeMax DO
  458.             EnableCheck(c, TRUE, (c - cSizeBase) = fTextSpecs.theFontSize);
  459.  
  460.         aStyle := fTextSpecs.theStyle;
  461.         EnableCheck(cPlainText, TRUE, aStyle = []);
  462.         EnableCheck(cBold, TRUE, bold IN aStyle);
  463.         EnableCheck(cItalic, TRUE, italic IN aStyle);
  464.         EnableCheck(cUnderline, TRUE, underline IN aStyle);
  465.         EnableCheck(cOutline, TRUE, outline IN aStyle);
  466.         EnableCheck(cExtend, TRUE, extend IN aStyle);
  467.         EnableCheck(cCondense, TRUE, condense IN aStyle);
  468.         EnableCheck(cShadow, TRUE, shadow IN aStyle);
  469.  
  470.         sd := fTEView.fSizeDeterminer[h];
  471.         EnableCheck(cWidthFrame, TRUE, (sd = sizeFrame));
  472.         EnableCheck(cWidthOnePage,    TRUE, (sd = sizePage));
  473.         EnableCheck(cWidthView,  TRUE, (sd = sizeFixed));
  474.  
  475.         sd := fTEView.fSizeDeterminer[v];
  476.         EnableCheck(cHeightFrame,  TRUE, (sd = sizeFrame));
  477.         EnableCheck(cHeightPages,  TRUE, (sd = sizeFillPages));
  478.         EnableCheck(cHeightText,  TRUE, (sd = sizeVariable));
  479.         EnableCheck(cHeightConst,  TRUE, (sd = sizeFixed));
  480.  
  481.         just := fTextSpecs.theJustification;
  482.         EnableCheck(cJustLeft, TRUE, (just = teJustLeft));
  483.         EnableCheck(cJustCenter, TRUE, (just = teJustCenter));
  484.         EnableCheck(cJustRight, TRUE, (just = teJustRight));
  485.  
  486.         IF fSpecsChanged THEN
  487.             OutlineFontSizes(fTextSpecs.theFontNumber);
  488.  
  489.         fSpecsChanged := FALSE;
  490.     END;
  491.  
  492.  
  493.     {$S AWriteFile}
  494.     PROCEDURE TTextDocument.DoWrite(aRefNum: INTEGER; makingCopy: BOOLEAN);
  495.         VAR numChars:         LONGINT;
  496.             hTextSpecs:        TextSpecsHdl;
  497.             tempHandle:        Handle;
  498.     BEGIN
  499.         {Write out the text}
  500.         numChars := GetHandleSize(fText);
  501.         FailOSErr(FSWrite(aRefNum, numChars, fText^));
  502.         
  503.         {Write the text specification resource, after converting it to a handle}
  504.         hTextSpecs := TextSpecsHdl(NewHandle(SIZEOF(TextSpecs)));
  505.         FailNIL(hTextSpecs);
  506.         hTextSpecs^^ := fTextSpecs;
  507.         AddResource(Handle(hTextSpecs), kTextSpecsRsrcType,
  508.                     kTextSpecsRsrcID, '');
  509.         FailResError;
  510.         
  511.         {Write the print info resource.  Note we can't use MacApp for this
  512.             because MacApp will write the print info into the data fork.
  513.             Note also--we must copy the print info resource to another handle
  514.             because the Resource Manager will dispose of the resource handles
  515.             when a resource fork is closed.}
  516.         tempHandle := fPrintInfo;
  517.         FailOSErr(HandTohand(tempHandle));
  518.         AddResource(tempHandle, kPrintInfoRsrcType, kPrintInfoRsrcID, '');
  519.         FailResError;
  520.     END;
  521.  
  522.  
  523.     {$S AClose}
  524.     PROCEDURE TTextDocument.FreeData; OVERRIDE;
  525.     BEGIN
  526.         SetHandleSize(fText, 0);
  527.     END;
  528.  
  529.  
  530.     {$S ARes}
  531.     PROCEDURE TTextDocument.InstallTextSpecs(specs: TextSpecs);
  532.     
  533.     VAR
  534.         savedPort:        GrafPtr;
  535.         tempPort:        GrafPort;
  536.         newInfo:        FontInfo;
  537.  
  538.     BEGIN
  539.         {Make sure the font info record is correct.  Note that we may have
  540.             to do this when the window isn't around, so roll our own
  541.             GrafPort.}
  542.         GetPort(savedPort);
  543.         OpenPort(@tempPort);
  544.         WITH specs DO
  545.             BEGIN
  546.             TextFont(theFontNumber);
  547.             TextSize(theFontSize);
  548.             TextFace(theStyle);
  549.             END;
  550.         GetFontInfo(newInfo);
  551.         ClosePort(@tempPort);
  552.         SetPort(savedPort);
  553.  
  554.         fTextSpecs := specs;
  555.         fSpecsChanged := TRUE;
  556.         
  557.         WITH fTEView, specs DO
  558.             BEGIN
  559.             fFont := theFontNumber;
  560.             fSize := theFontSize;
  561.             fFontInfo := newInfo;
  562.             WITH fHTE^^ DO
  563.                 BEGIN
  564.                 WITH newInfo DO
  565.                     BEGIN
  566.                     fontAscent := ascent;
  567.                     lineHeight := ascent+descent+leading;
  568.                     END;
  569.                 txSize := theFontSize;
  570.                 txFont := theFontNumber;
  571.                 txFace := theStyle;
  572.                 just := theJustification;
  573.                 fFrame.fScrollUnit.v := lineHeight;
  574.                 END;
  575.             END;
  576.         fTEView.RecalcText;
  577.         fTEView.DoPagination;
  578.     END;
  579.  
  580.  
  581.     {$S AReadFile}
  582.     PROCEDURE TTextDocument.ShowReverted;
  583.     
  584.     BEGIN
  585.         InstallTextSpecs(fTextSpecs);
  586.         TESetSelect(0, 0, fTEView.fHTE);
  587.         INHERITED ShowReverted;
  588.     END;
  589.     
  590.  
  591.  
  592.     {$S ARes}
  593.     PROCEDURE OutlineFontSizes(fontNum: INTEGER);
  594.         VAR c:    CmdNumber;
  595.     BEGIN
  596.         FOR c := cSizeMin TO cSizeMax DO
  597.             BEGIN
  598.             IF RealFont(fontNum, c - cSizeBase) THEN
  599.                 SetStyle(c, [outline])
  600.             ELSE
  601.                 SetStyle(c, []);
  602.             END;
  603.     END;
  604.  
  605.  
  606.     {$S ASelCommand}
  607.     PROCEDURE TTextCommand.ITextCommand(itsCmdNumber: CmdNumber;
  608.                                         itsTextDocument: TTextDocument;
  609.                                         itsTEView: TTEView;
  610.                                         itsFontNumber: INTEGER;
  611.                                         itsFontSize: INTEGER;
  612.                                         itsStyle: Style;
  613.                                         itsJustification: INTEGER);
  614.         VAR info:    FontInfo;
  615.     BEGIN
  616.         ICommand(itsCmdNumber);
  617.         fTEView := itsTEView;
  618.         fTextDocument := itsTextDocument;
  619.         WITH fOldTextSpecs, itsTEView.fHTE^^ DO
  620.             BEGIN
  621.             theFontNumber := txFont;
  622.             theFontSize := txSize;
  623.             theStyle := txFace;
  624.             theJustification := just;
  625.             END;
  626.  
  627.         WITH fNewTextSpecs DO
  628.             BEGIN
  629.             theFontNumber := itsFontNumber;
  630.             theFontSize := itsFontSize;
  631.             theStyle := itsStyle;
  632.             theJustification := itsJustification;
  633.             END;
  634.      END;
  635.  
  636.  
  637.     {$S ADoCommand}
  638.     PROCEDURE TTextCommand.DoIt; OVERRIDE;
  639.     BEGIN
  640.         fTextDocument.InstallTextSpecs(fNewTextSpecs);
  641.     END;
  642.  
  643.  
  644.     {$S ADoCommand}
  645.     PROCEDURE TTextCommand.UndoIt; OVERRIDE;
  646.     BEGIN
  647.         fTextDocument.InstallTextSpecs(fOldTextSpecs);
  648.     END;
  649.  
  650.  
  651.     {$S ADoCommand}
  652.     PROCEDURE TTextCommand.RedoIt; OVERRIDE;
  653.     BEGIN
  654.         fTextDocument.InstallTextSpecs(fNewTextSpecs);
  655.     END;
  656.  
  657.  
  658.  
  659.